package com.e3.basdoc.currency.client;

import java.util.List;

import com.e3.basdoc.currency.model.CurrencyModel;
import com.e3.basdoc.currency.model.CurrencyQC;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.web.core.client.GwtAsyncCallback;
import com.e3.web.core.model.SuperQC;
import com.e3.web.widget.client.MyField;
import com.extjs.gxt.ui.client.widget.form.Field;

public class CurrencyQueryDialog extends TGFQueryDialog<CurrencyModel> {
	
	private CurrencyRPCServiceAsync service = CurrencyRPCService.Util.getInstance();

	@Override
	protected List<Field<?>> getFormFields() {
		return CurrencyHelper.INSTANCE.getFormFields();
	}

	@Override
	protected SuperQC getQueryCondition() {
		MyField<?> field = getMyFormField(CurrencyModel.CODE);
		String code = (String)field.getFieldValue();
		field = getMyFormField(CurrencyModel.NAME);
		String name = (String)field.getFieldValue();
		field = getMyFormField(CurrencyModel.SIGN);
		String sign = (String)field.getFieldValue();
		
		final CurrencyQC qc = new CurrencyQC();
		qc.setCode(code);
		qc.setName(name);
		qc.setSign(sign);
		return qc;
	}

	@Override
	protected void executeQueryService(SuperQC qc,GwtAsyncCallback<List<CurrencyModel>> callback) {
		service.getCurrencyByCondition((CurrencyQC)qc, getQueryAsyncCallBack(qc));
	}
}
